%{
#include <stdio.h>
#include "atom.h"
#include "dtd.h"
#include "dtd2.h"
#include "y.tab.h"
%}

%%
"<!ELEMENT"	{
		    return (ELESTART);
		}
"<!ATTLIST"	{
		    return (ATTSTART);
		}
#FIXED		{
		    return (ATTFIXED);
		}
#REQUIRED	{
		    return (ATTREQUIRED);
		}
#IMPLIED	{
		    return (ATTIMPLIED);
		}
#implied	{
		    return (ATTIMPLIED);
		}
EMPTY		{
		    return (EMPTYLIST);
		}


[-+|O>()&,]	{
		    return(*yytext);
		}

[*?]		{
		    ;
		}

"\""[^"]*"\""	{
		    char *cp;

		    yylval.string = (char *)strdup(yytext+1);
		    cp = (char *)strchr(yylval.string, '"');
		    *cp = NULL;
		    return(QUOTE);
		}
"'"[^"]*"'"	{
		    char *cp;

		    yylval.string = (char *)strdup(yytext+1);
		    cp = (char *)strchr(yylval.string, '\'');
		    *cp = NULL;
		    return(QUOTE);
		}

#PCDATA		{
		    yylval.string = (char *)strdup("PCDATA");
		    return (WORD);
		}

[a-zA-Z0-9#-]+	{
		    /*
		    fprintf(stderr, "Word: %s\n", yytext);
		    */
		    /* Simple word */
		    yylval.string = (char *)strdup(yytext);
		    return (WORD);
		}
[\t\n ]+		{
		}
.		{
		    fprintf(stderr, "%d: Unknown character: '%s'\n", yylineno, yytext);
		}

%%

int
yygetlineno()
{
    return (yylineno);
}
